<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>eventbase &mdash; GOZERWAVE v0.1 BETA documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.1 BETA',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="GOZERWAVE v0.1 BETA documentation" href="../index.html" />
    <link rel="next" title="examples" href="examples.html" />
    <link rel="prev" title="config" href="config.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="examples.html" title="examples"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="config.html" title="config"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="eventbase">
<h1>eventbase<a class="headerlink" href="#eventbase" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-gozerlib.eventbase">
<h2>description<a class="headerlink" href="#module-gozerlib.eventbase" title="Permalink to this headline">¶</a></h2>
<p>base class of all events.</p>
<dl class="class">
<dt id="gozerlib.eventbase.EventBase">
<em class="property">class </em><tt class="descclassname">gozerlib.eventbase.</tt><tt class="descname">EventBase</tt><a class="headerlink" href="#gozerlib.eventbase.EventBase" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a title="gozerlib.utils.lazydict.LazyDict" class="reference external" href="utils/lazydict.html#gozerlib.utils.lazydict.LazyDict"><tt class="xref docutils literal"><span class="pre">gozerlib.utils.lazydict.LazyDict</span></tt></a></p>
<p>basic event class.</p>
<dl class="method">
<dt id="gozerlib.eventbase.EventBase.checkqueues">
<tt class="descname">checkqueues</tt><big>(</big><em>resultlist</em><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.checkqueues" title="Permalink to this definition">¶</a></dt>
<dd><p>check if resultlist is to be sent to the queues. if so do it</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>resultlist</em> (list) &#8211; list of results to send to queues</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">boolean</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.copyin">
<tt class="descname">copyin</tt><big>(</big><em>eventin</em><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.copyin" title="Permalink to this definition">¶</a></dt>
<dd><p>copy in an event.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>eventin</em> (gozerlib.eventbase.EventBase) &#8211; event to copy</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">self</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.done">
<tt class="descname">done</tt><big>(</big><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.done" title="Permalink to this definition">¶</a></dt>
<dd>tell the user we are done.</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.less">
<tt class="descname">less</tt><big>(</big><em>what</em><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.less" title="Permalink to this definition">¶</a></dt>
<dd><p>split up in parts of 1000 chars overflowing on word boundaries.
put remaining txt into outcache.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>what</em> (string) &#8211; text to split</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">list of 1st and second string to display</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.makeargs">
<tt class="descname">makeargs</tt><big>(</big><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.makeargs" title="Permalink to this definition">¶</a></dt>
<dd>make arguments and rest attributes from self.txt.</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.makeresponse">
<tt class="descname">makeresponse</tt><big>(</big><em>txt</em>, <em>result=</em><span class="optional">[</span><span class="optional">]</span>, <em>nritems=False</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.makeresponse" title="Permalink to this definition">¶</a></dt>
<dd><p>create response.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><em>txt</em> (string) &#8211; text prepended to result</li>
<li><em>result</em> (list of results (strings)) &#8211; </li>
<li><em>nritems</em> (boolean) &#8211; whether items should be numbered (not used now)</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.missing">
<tt class="descname">missing</tt><big>(</big><em>txt</em><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.missing" title="Permalink to this definition">¶</a></dt>
<dd><p>display missing arguments.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>txt</em> (string) &#8211; txt to display</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.parse">
<tt class="descname">parse</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.parse" title="Permalink to this definition">¶</a></dt>
<dd>overload this.</dd></dl>

<dl class="method">
<dt id="gozerlib.eventbase.EventBase.reply">
<tt class="descname">reply</tt><big>(</big><em>txt</em>, <em>resultlist=</em><span class="optional">[</span><span class="optional">]</span>, <em>nritems=False</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#gozerlib.eventbase.EventBase.reply" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
default reply .. OVERLOAD THIS .. defaults output to stdout.</blockquote>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><em>txt</em> (string) &#8211; text prepended to result</li>
<li><em>result</em> (list of results (strings)) &#8211; </li>
<li><em>nritems</em> (boolean) &#8211; whether items should be numbered (not used now)</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="code">
<h2>code<a class="headerlink" href="#code" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre>  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251</pre></td><td class="code"><div class="highlight"><pre><span class="c"># gozerlib/eventbase.py</span>
<span class="c">#</span>
<span class="c">#</span>

<span class="sd">&quot;&quot;&quot; base class of all events. &quot;&quot;&quot;</span>

<span class="c">## gozerlib imports</span>

<span class="kn">from</span> <span class="nn">utils.lazydict</span> <span class="kn">import</span> <span class="n">LazyDict</span>
<span class="kn">from</span> <span class="nn">utils.generic</span> <span class="kn">import</span> <span class="n">splittxt</span>
<span class="kn">from</span> <span class="nn">less</span> <span class="kn">import</span> <span class="n">Less</span>

<span class="c">## basic imports</span>

<span class="kn">import</span> <span class="nn">Queue</span>
<span class="kn">import</span> <span class="nn">copy</span>
<span class="kn">import</span> <span class="nn">types</span>

<span class="k">class</span> <span class="nc">EventBase</span><span class="p">(</span><span class="n">LazyDict</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; basic event class. &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">LazyDict</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bot</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="s">&quot;notset&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">origin</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cmnd</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">iswave</span> <span class="o">=</span> <span class="bp">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">isweb</span> <span class="o">=</span> <span class="bp">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">isxmpp</span> <span class="o">=</span> <span class="bp">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">properties</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">context</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">response</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">auth</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">userhost</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">resource</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">channel</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">origtxt</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">txt</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">args</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rest</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">queues</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">inqueue</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">aliased</span> <span class="o">=</span> <span class="bp">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">replied</span> <span class="o">=</span> <span class="bp">False</span>
        <span class="k">return</span> <span class="bp">self</span>

    <span class="k">def</span> <span class="nf">__deepcopy__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; deepcopy an event. &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="n">EventBase</span><span class="p">()</span><span class="o">.</span><span class="n">copyin</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_raw</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">txt</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; put rawstring to the server .. overload this &quot;&quot;&quot;</span>

        <span class="k">print</span> <span class="n">txt</span>

    <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; overload this. &quot;&quot;&quot;</span>

        <span class="k">pass</span>

    <span class="k">def</span> <span class="nf">copyin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">eventin</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">            copy in an event.</span>

<span class="sd">            :param eventin: event to copy</span>
<span class="sd">            :type eventin: gozerlib.eventbase.EventBase</span>
<span class="sd">            :rtype: self</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">eventin</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">eventin</span><span class="o">.</span><span class="n">has_key</span><span class="p">(</span><span class="s">&#39;queues&#39;</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">queues</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">eventin</span><span class="o">.</span><span class="n">queues</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">eventin</span><span class="o">.</span><span class="n">has_key</span><span class="p">(</span><span class="s">&#39;inqueue&#39;</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">inqueue</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">eventin</span><span class="o">.</span><span class="n">inqueue</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span>

    <span class="k">def</span> <span class="nf">makeargs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; make arguments and rest attributes from self.txt. &quot;&quot;&quot;</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">txt</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mf">1</span><span class="p">:]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">rest</span> <span class="o">=</span> <span class="s">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">)</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">args</span> <span class="o">=</span> <span class="bp">None</span>

    <span class="k">def</span> <span class="nf">makeresponse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">txt</span><span class="p">,</span> <span class="n">result</span><span class="o">=</span><span class="p">[],</span> <span class="n">nritems</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">            create response. </span>

<span class="sd">            :param txt: text prepended to result</span>
<span class="sd">            :type txt: string</span>
<span class="sd">            :param result:</span>
<span class="sd">            :type result: list of results (strings)</span>
<span class="sd">            :param nritems: whether items should be numbered (not used now)</span>
<span class="sd">            :type nritems: boolean</span>
<span class="sd">            :rtype: string</span>

<span class="sd">        &quot;&quot;&quot;</span>


        <span class="k">if</span> <span class="n">result</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> <span class="o">==</span> <span class="n">types</span><span class="o">.</span><span class="n">DictType</span><span class="p">:</span>
                <span class="n">res</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">res</span> <span class="o">=</span> <span class="n">txt</span> <span class="o">+</span> <span class="s">&#39; &#39;</span> <span class="o">+</span> <span class="s">&#39; .. &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">res</span> <span class="o">=</span> <span class="n">txt</span>

        <span class="k">return</span> <span class="n">res</span>
 
    <span class="k">def</span> <span class="nf">reply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">txt</span><span class="p">,</span> <span class="n">resultlist</span><span class="o">=</span><span class="p">[],</span> <span class="n">nritems</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">             default reply .. OVERLOAD THIS .. defaults output to stdout.</span>

<span class="sd">            :param txt: text prepended to result</span>
<span class="sd">            :type txt: string</span>
<span class="sd">            :param result:</span>
<span class="sd">            :type result: list of results (strings)</span>
<span class="sd">            :param nritems: whether items should be numbered (not used now)</span>
<span class="sd">            :type nritems: boolean</span>
<span class="sd">            :rtype: string</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">queues</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">queue</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">queues</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">resultlist</span><span class="p">:</span>
                    <span class="n">queue</span><span class="o">.</span><span class="n">put_nowait</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">makeresponse</span><span class="p">(</span><span class="n">txt</span><span class="p">,</span> <span class="n">resultlist</span><span class="p">,</span> <span class="n">nritems</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">less</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
        <span class="k">print</span> <span class="n">res</span>
        <span class="k">print</span> <span class="n">result</span>
        <span class="k">return</span> <span class="bp">self</span>

    <span class="k">def</span> <span class="nf">missing</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">txt</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">            display missing arguments. </span>

<span class="sd">            :param txt: txt to display</span>
<span class="sd">            :type txt: string</span>
<span class="sd">            :rtype: None</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">origtxt</span><span class="p">:</span>
            <span class="n">splitted</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">origtxt</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>

            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bot</span><span class="o">.</span><span class="n">nick</span> <span class="ow">in</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">0</span><span class="p">]:</span>

                <span class="k">try</span><span class="p">:</span>
                    <span class="n">cmnd</span> <span class="o">=</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span>
                <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
                    <span class="n">cmnd</span> <span class="o">=</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>

            <span class="k">elif</span> <span class="s">&#39;cmnd&#39;</span> <span class="ow">in</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">0</span><span class="p">]:</span>

                <span class="k">try</span><span class="p">:</span>
                    <span class="n">cmnd</span> <span class="o">=</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">2</span><span class="p">]</span>
                <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
                    <span class="n">cmnd</span> <span class="o">=</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>

            <span class="k">else</span><span class="p">:</span>

                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">msg</span><span class="p">:</span>
                    <span class="n">cmnd</span> <span class="o">=</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">aliased</span><span class="p">:</span>
                        <span class="n">cmnd</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">aliased</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">cmnd</span> <span class="o">=</span> <span class="n">splitted</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="n">cmnd</span> <span class="o">+</span> <span class="s">&#39; &#39;</span> <span class="o">+</span> <span class="n">txt</span><span class="p">)</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;missing origtxt: </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">txt</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">checkqueues</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resultlist</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">            check if resultlist is to be sent to the queues. if so do it</span>

<span class="sd">            :param resultlist: list of results to send to queues</span>
<span class="sd">            :type resultlist: list</span>
<span class="sd">            :rtype: boolean</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">queues</span><span class="p">:</span>

            <span class="k">for</span> <span class="n">queue</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">queues</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">resultlist</span><span class="p">:</span>
                    <span class="n">queue</span><span class="o">.</span><span class="n">put_nowait</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>

            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">done</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; tell the user we are done. &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;done&#39;</span><span class="p">)</span>


    <span class="k">def</span> <span class="nf">less</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">what</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            split up in parts of 1000 chars overflowing on word boundaries.</span>
<span class="sd">            put remaining txt into outcache.</span>

<span class="sd">            :param what: text to split</span>
<span class="sd">            :type what: string</span>
<span class="sd">            :rtype: list of 1st and second string to display</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">what</span> <span class="o">=</span> <span class="n">what</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
        <span class="n">txtlist</span> <span class="o">=</span> <span class="n">splittxt</span><span class="p">(</span><span class="n">what</span><span class="p">,</span> <span class="mf">1000</span><span class="p">)</span>
        <span class="n">size</span> <span class="o">=</span> <span class="mf">0</span>

        <span class="c"># send first block</span>
        <span class="n">res</span> <span class="o">=</span> <span class="n">txtlist</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>

        <span class="c"># see if we need to store output in less cache</span>
        <span class="n">result</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">txtlist</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mf">2</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">bot</span><span class="o">.</span><span class="n">outcache</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">userhost</span><span class="p">,</span> <span class="n">txtlist</span><span class="p">[</span><span class="mf">1</span><span class="p">:])</span>
            <span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">txtlist</span><span class="p">)</span> <span class="o">-</span> <span class="mf">2</span>
            <span class="n">result</span> <span class="o">=</span> <span class="n">txtlist</span><span class="p">[</span><span class="mf">1</span><span class="p">:</span><span class="mf">2</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">size</span><span class="p">:</span>
                <span class="n">result</span> <span class="o">+=</span> <span class="s">&quot; (+</span><span class="si">%s</span><span class="s">)&quot;</span> <span class="o">%</span> <span class="n">size</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">txtlist</span><span class="p">)</span> <span class="o">==</span> <span class="mf">2</span><span class="p">:</span>
                <span class="n">result</span> <span class="o">=</span> <span class="n">txtlist</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span>

        <span class="k">return</span> <span class="p">[</span><span class="n">res</span><span class="p">,</span> <span class="n">result</span><span class="p">]</span>
</pre></div>
</td></tr></table></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="../index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">eventbase</a><ul>
<li><a class="reference external" href="#module-gozerlib.eventbase">description</a></li>
<li><a class="reference external" href="#code">code</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="config.html"
                                  title="previous chapter">config</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="examples.html"
                                  title="next chapter">examples</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/gozerlib/eventbase.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="examples.html" title="examples"
             >next</a> |</li>
        <li class="right" >
          <a href="config.html" title="config"
             >previous</a> |</li>
        <li><a href="../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2009, Bart Thate.
      Last updated on Nov 14, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
    </div>
  </body>
</html>